<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get" action="">
<?include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>日期</th>	
	<td>
		<input class="datepicker" name="begin_time" value="<?=isset($_GET['begin_time']) ? $_GET['begin_time'] : ''?>" /> to 
		<input class="datepicker" name="end_time" value="<?=isset($_GET['end_time']) ? $_GET['end_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>产品编号</th>
	<td><input type="text" name="product_number" value="<?=isset($_GET['product_number']) ? $_GET['product_number'] : ''?>" /></td>
</tr>
<tr>
	<th>仓库</th>
	<td>
		<select name="warehouse_id">
			<?foreach ($warehouse as $w):?>
			<option value="<?=$w['id']?>" <?if (isset($_GET['warehouse_id']) && $_GET['warehouse_id']==$w['id']):?>selected="selected"<?endif;?>><?=$w['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" value="查询" class="button" /></td>
</tr>
</table></form></fieldset>
<?if (isset($log)):?>
<p>产品编号：<?=$product_basic['number']?></p>
<p>产品名称：<?=$product_basic['name']?></p>
<p><?=$product_warehouse['warehouse_name']?> 库存编码：<?=$product_warehouse['storage_number']?></p>
<p>实际库存：<?=$product_warehouse['actual_quantity']?></p>
<table class="list_table" width="100%">
<tr>
	<th>时间</th>
	<th>类型</th>
	<th>初始数量</th>
	<th>入库数量</th>
	<th>出库数量</th>
	<th>经手人</th>
</tr>
<?$init = $in = $out = 0;?>
<?foreach ($log as $l):?>
<?$init += $l['init_quantity'];$in += $l['in_quantity']; $out += $l['out_quantity'];?>
<tr>
	<td><?=$l['time']?></td>
	<td><?=Helper_BSS_Normal::getIniOne('inventory_log_type', 'value', $l['type'], 'name')?></td>
	<td><?=$l['init_quantity']?></td>
	<td><?=$l['in_quantity']?></td>
	<td><?=$l['out_quantity']?></td>
	<td><?=$l['user_name']?></td>
</tr>
<?endforeach;?>
<tr>
	<td colspan="2">总计</td>
	<td><?=$init?></td>
	<td><?=$in?></td>
	<td><?=$out?></td>
	<td></td>
</tr>
</table>
<?endif;?>
<?php $this->_endblock();?>